package com.example.demo.mapper;

import com.example.demo.entity.Recharge;
import com.example.demo.entity.Recharge1;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RechargeMapper {
    @Insert("insert into recharge(CustomerId,SumOM,Date) values(#{CustomerId},#{SumOM},#{Date})")
    void insertRecharge(Recharge recharge);

    @Select("select * from recharge order by Date desc")
    List<Recharge> selectRecharge();

    @Select("select * from recharge where CustomerId=#{id} order by Date desc")
    List<Recharge> selectRecharge1(String id);

    @Delete("delete from recharge where RechargeId=#{id}")
    void deleteRecharge(String id);

    @Select("select Sum(SumOM) as SumOm,CustomerId,DATE_FORMAT(Date, '%Y-%m') as Date from recharge where CustomerId=#{id} group by  DATE_FORMAT(Date, '%Y-%m') desc")
    List<Recharge1> selectRechargeByY(String id);

    @Select("select Sum(SumOM) as SumOm,CustomerId,DATE_FORMAT(Date, '%Y-%m-%d') as Date from recharge where CustomerId=#{id} group by  DATE_FORMAT(Date, '%Y-%m-%d') desc")
    List<Recharge1> selectRechargeByD(String id);
}
